package com.morty.base.enums;

public enum RetEnum {
    SUCCESS(200, "success"),
    INTERNAL_ERROR(500, "内部异常"),
    VERIFY_APITOKEN_ERROR(10000, "apitoken不可用"),
    PARAMETER_EMPTY(10001, "参数不能为空"),
    PARAMETER_NOT_ALLOW(10002, "参数不正确"),
    TOKEN_VERIFY_FAIL(10003, "token认证失败"),

    THIRD_PARTY_BUSINESS_ERROR_CODE(299, "第三方信息错误码");

    private int code;
    private String message;

    private RetEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return this.code;
    }

    public String getMessage() {
        return this.message;
    }

    public static RetEnum getRetEnum(int code) {
        if (code == 0) {
            return null;
        }

        RetEnum[] values = RetEnum.values();
        for (RetEnum e : values) {
            if (e.getCode() == code) {
                return e;
            }
        }
        return null;
    }
}
